package chapter10;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/4/13 14:50
 */
class Egg2 {
    private Yolk yolk = new Yolk();  //1

    public Egg2() {
        System.out.println("new Egg2");  //2
    }

    public void insertYolk(Yolk yolk) {
        this.yolk = yolk;
    }

    public void g() {
        yolk.f();
    }

    protected class Yolk {
        public Yolk() {
            System.out.println("Egg2.Yolk");
        }

        public void f() {
            System.out.println("Egg2.Yolk.fI()");
        }
    }
}

public class BigEgg2 extends Egg2 {
    public BigEgg2() {
        insertYolk(new Yolk()); //3
    }

    public static void main(String[] args) {
        BigEgg2 bigEgg2 = new BigEgg2();
        bigEgg2.g();
    }

    public class Yolk extends Egg2.Yolk {
        public Yolk() {
            System.out.println("BigEgg2.Yolk");
        }

        @Override
        public void f() {
            System.out.println("BigEgg2.Yolk.f()");
        }
    }
}
